import Vue from 'vue'
import Router from 'vue-router'

import Login from '@/pages/login/login'
import NotFound from '@/pages/errorPage/404'
import Forbidden from '@/pages/errorPage/403'
import Layout from '@/pages/layout/index'
/* 订单管理 */
const Product = () => import('@/pages/product-manage')
const ProductList = () => import('@/pages/product-manage/product/product-list.vue')

/* 文章管理 */
const Article = () => import('@/pages/article-manage')
const ArticleList = () => import('@/pages/article-manage/news/index.vue')
const ArticleTypeList = () => import('@/pages/article-manage/article-type/index.vue')

/* 轮播管理 */
const Carouse = () => import('@/pages/carousel-manage')
const CarouseList = () => import('@/pages/carousel-manage/carousel-list/index.vue')

/* 下载链接管理 */
const Download = () => import('@/pages/download-manage')
const DownloadList = () => import('@/pages/download-manage/download-list/index.vue')

/* 法律信息管理 */
const Document = () => import('@/pages/document-manage')
const DocumentList = () => import('@/pages/document-manage/document-list/index.vue')


Vue.use(Router)

/* 初始路由 */
export default new Router({
    routes: [
        {
            path: '/login',
            component: Login
        }
    ]
})

/* 准备动态添加的路由 */
export const DynamicRoutes = [
    {
        path: '',
        component: Layout,
        name: 'container',
        redirect: 'product',
        meta: {
            requiresAuth: true,
            name: '首页'
        },
        children: [
            {
                path: '/product',
                component: Product,
                name: 'product-manage',
                redirect: '/product/list',
                meta: {
                    name: '产品管理',
                    icon: 'example'
                },
                children: [
                    {
                        path: 'list',
                        name: 'order-list',
                        component: ProductList,
                        meta: {
                            name: '产品列表',
                            icon: 'table'
                        }
                    }
                ]
            },
            {
                path: '/article',
                component: Article,
                name: 'article-manage',
                redirect: '/article/news',
                meta: {
                    name: '文章管理',
                    icon: 'example'
                },
                children: [
                    {
                        path: 'news',
                        name: 'news-list',
                        component: ArticleList,
                        meta: {
                            name: '文章列表',
                            icon: 'table'
                        }
                    },
                    {
                        path: 'types',
                        name: 'types-list',
                        component: ArticleTypeList,
                        meta: {
                            name: '文章类型',
                            icon: 'table'
                        }
                    }
                ]
            },
            {
                path: '/carousel',
                component: Carouse,
                name: 'carousel-manage',
                redirect: '/carousel/list',
                meta: {
                    name: '轮播管理',
                    icon: 'example'
                },
                children: [
                    {
                        path: 'list',
                        name: 'carousel-list',
                        component: CarouseList,
                        meta: {
                            name: '轮播列表',
                            icon: 'table'
                        }
                    }
                ]
            },
            {
                path: '/download',
                component: Download,
                name: 'download-manage',
                redirect: '/download/list',
                meta: {
                    name: '下载链接管理',
                    icon: 'example'
                },
                children: [
                    {
                        path: 'list',
                        name: 'download-list',
                        component: DownloadList,
                        meta: {
                            name: '下载链接',
                            icon: 'table'
                        }
                    }
                ]
            },
            {
                path: '/document',
                component: Document,
                name: 'document-manage',
                redirect: '/document/list',
                meta: {
                    name: '法律信息',
                    icon: 'example'
                },
                children: [
                    {
                        path: 'list',
                        name: 'document-list',
                        component: DocumentList,
                        meta: {
                            name: '协议列表',
                            icon: 'table'
                        }
                    }
                ]
            }
        ]
    },
    {
        path: '/403',
        component: Forbidden
    },
    {
        path: '*',
        component: NotFound
    }
]
